package benny.ApkposStore.Adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import benny.ApkposStore.R;
import benny.ApkposStore.model.View_dian;

public class CailistAdapter extends BaseAdapter {

	private Context context;
	private List<View_dian> list;
	private LayoutInflater mInflater;
	//private TextPaint tp = null;
	public CailistAdapter(Context context, List<View_dian> list) {
		this.context = context;
		this.list = list;
		mInflater = LayoutInflater.from(this.context);
	}

	public int getCount() {
		// TODO Auto-generated method stub
		if (list != null){
		return list.size();	
		}			
		else
			return 0;
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		if (list != null)
			return list.get(position);
		else
			return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressWarnings("unused")
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Dishholder dishholder = null;
		if (dishholder == null) {

			dishholder = new Dishholder();
			convertView = mInflater.inflate(R.layout.dishbtn, null);
			dishholder.dishname = (TextView) convertView
					.findViewById(R.id.dishname);			
			dishholder.dishunit = (TextView) convertView
					.findViewById(R.id.dishunit);			
			convertView.setTag(dishholder);
			
		} else {
			dishholder = (Dishholder) convertView.getTag();
		}
		/*
		 * ///绑定点击事件 holder.roomtitle.setOnClickListener((OnClickListener)
		 * list.get(position).get("listen")); 
		 * if(Boolean.parseBoolean(list.get(position).get("bl").toString()))
		 * holder.roomtitle.setEnabled(true); else
		 * holder.roomtitle.setEnabled(false);
		 */
		
//   	中文加粗
//		tp = holder.roomtitle.getPaint();
//		tp.setFakeBoldText(true);
		
		dishholder.dishname
			.setText(list.get(position).getDish_name());			
		dishholder.DclaVar=
			list.get(position).getDish_class_id();	
		dishholder.ORDL_VAR=
				list.get(position).getInner_rank_id();	
		dishholder.JGLX_VAR=
				list.get(position).getPrice_type()+"";	
		dishholder.DPRI_FLO=
				(float) (list.get(position).getUnit_price()*0.01);	
		dishholder.DNBR_VAR=
				list.get(position).getId()+"";	
		dishholder.JSMM_VAR=
				list.get(position).getSearch_name();	
		dishholder.DDET_VAR=
				list.get(position).getUnit();	
		dishholder.PDET_VAR=
				list.get(position).getPrinter_name();	
		dishholder.PDET_VAR_IP=
				list.get(position).getPrinter_ip();	
		dishholder.DNAM_VAR=
				list.get(position).getDish_name();
		dishholder.IS_PRINT=
				list.get(position).getIs_print_item();
		
		dishholder.dishunit
		.setText(dishholder.DPRI_FLO+"/"+dishholder.DDET_VAR);	
		
		return convertView;
	}

	public final class Dishholder {
		public TextView dishname;
		public TextView dishunit;
		public float  DclaVar;
		public float  ORDL_VAR;
		public String  JGLX_VAR;
		public float  DPRI_FLO;
		public String  DNBR_VAR;
		public String  JSMM_VAR;
		public String  PDET_VAR;
		public String  PDET_VAR_IP;
		public int  IS_PRINT;
		public String  DDET_VAR;
		public String  DNAM_VAR;
	}
}